//
//  UIApplication+GQHApplication.m
//  Seed
//
//  Created by GuanQinghao on 21/03/2018.
//  Copyright © 2018 GuanQinghao. All rights reserved.
//

#import "UIApplication+GQHApplication.h"

@implementation UIApplication (GQHApplication)

// 应用程序版本号
- (NSString *)qh_applicationShortVersion {
    
    return [NSBundle.mainBundle.infoDictionary objectForKey:@"CFBundleShortVersionString"];
}

// 应用程序构建版本号
- (NSString *)qh_applicationBuildVersion {
    
    return [NSBundle.mainBundle.infoDictionary objectForKey:@"CFBundleVersion"];
}

// 应用程序名称
- (NSString *)qh_applicationDisplayName {
    
    return [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
}

// 应用程序唯一编号
- (NSString *)qh_applicationBundleID {
    
    return [NSBundle.mainBundle.infoDictionary objectForKey:@"CFBundleIdentifier"];
}

// documents位置
- (NSURL *)qh_documentsURL {
    
    return [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].lastObject;
}

// documents路径
- (NSString *)documentsPath {
    
    return NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
}

// caches位置
- (NSURL *)qh_cachesURL {
    
    return [NSFileManager.defaultManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask].lastObject;
}

// caches路径
- (NSString *)qh_cachesPath {
    
    return NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject;
}

// library位置
- (NSURL *)qh_libraryURL {
    
    return [NSFileManager.defaultManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask].lastObject;
}

// library路径
- (NSString *)qh_libraryPath {
    
    return NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES).firstObject;
}

// 主屏幕大小
- (CGRect)qh_mainScreenBounds {
    
    return UIScreen.mainScreen.bounds;
}

// 主屏幕宽度
- (CGFloat)qh_mainScreenWidth {
    
    return CGRectGetWidth(UIScreen.mainScreen.bounds);
}

// 主屏幕高度
- (CGFloat)qh_mainScreenHeight {
    
    return CGRectGetHeight([UIScreen mainScreen].bounds);
}

@end
